<?php

FLEA::loadClass('Controller_BaseController');

class Controller_Member extends Controller_BaseController
{
	
    function Controller_Member() {
        
		$this->table = & FLEA::getSingleton('Table_Member');
		
		$dispatcher =& $this->_getDispatcher();
        $user = $dispatcher->getUser();
		if(isset($user['terminal_id'])&&null!=$user['terminal_id'])
			$this->conditions='terminal_id='.$user['terminal_id'];
    }
   
    function actionBoList(){
	   FLEA::loadClass('FLEA_Ajax');
		       
		$arr=$this->table->findAll($this->conditions,null,null,'member_id , name');

		echo '{Result:'.json_encode($arr).'}';
   }
   
   function _prepareData(& $meta) {
        $data = array();
		if(isset($_POST['mobile']))
			$_POST['consumer_id']=$_POST['mobile'];
        foreach ($meta as $m) {
            if (isset($_POST[$m['name']])&&trim($_POST[$m['name']])!='') {
				if($m['primaryKey']!=1)
					if($m['type']!='tinyint'){
					    if($m['name']=='password')
							$data[$m['name']] = crypt($_POST[$m['name']]);
						else
							$data[$m['name']] =strip_tags($_POST[$m['name']]);
					}
					else
						$data[$m['name']] = '1';
				else
					$data[$m['name']]=(int)$_POST[$m['name']];
            } else {
                if (isset($m['defaultValue'])) {
                    $data[$m['name']] = $m['defaultValue'];
                } else {
                    $data[$m['name']] = null;
                }
            }
        }
        return $data;
    }
}    
?>